%% Random Sin Wave
% Generate a sin wave from random points with a give noise

clear;
%%
% Totaly number of random values
x_num=100;

%%
% Ranges of x
x_min=0;
x_max=2*pi;

%%
% Total noise to add
noise=1;

h1=figure();
axis([0 2*pi -3 3]);
hold on;
h2=text(1,-1,'Loop: ');
for i=1:x_num
    x=(rand*(x_max-x_min)+x_min);
    y=sin(x)+rand*noise-rand*noise;
    plot(x,y);
    delete(h2);
    h2=text(1,-1,sprintf('Loop: %d',i));
    M(i)=getframe;
end
hold off;

movie(M);